<?php	
	$path_one = 'admin/admin_project';
	$path_two = 'admin/car_set';
	$filename = 'admin/car_set';
	require_once("header.php");
	require_once("admin_comm.php");
	require_once $_site->get_handlepath('project');
		
	$admin_obj = new admin();
	$user_info = $admin_obj->out_cookie();
	if($user_info['group']!=6){		
		exit('权限限制');
	}

	$result=$admin_obj->search_manage("id,account,name");
	$pid=request('pid',false,true,false,0);	
    
	$project_id=request('prid',false,true,false,0);
	$data=array();
    //查询项目信息
    if($pid){
    	$project_obj=new project();
    	$project_ary=$project_ary=$project_obj->project_by_uid($pid);
    	if($project_ary && !$project_id){
    		$project_id=$project_ary[0]['id'];
    	}
    	    
   		$data['admin']=true;
    
    	//统计查询信息
    	
    	$total_ary=$project_obj->get_records_date($pid,$project_id,$data);
    }    
    $type_ary=array(1=>'装车模式',2=>'计时模式',3=>'渣车模式');
?>
<script type="text/javascript" src="/static/artDialog/jquery.artDialog.js?skin=opera"></script>
<script type="text/javascript" charset="utf-8">
	loader.file({		
		skincss:['list']
	})	
	
    //修改记录
    var dialog=null;
	function editinfo(str,title){
	    dialog = art.dialog({
		    title: title,
		    content: str,
		    icon: 'warning',
		    lock: true,
		    cancel:false
		});	    
	}		

    function myDialog(str){
    	dialog.content(str);
    }
	
	var page=0;
	function del(date){		
		var pro=$("#project").val();	
		var title='【'+pro+' '+ date +'】';
		if(!confirm('该操作不能撤销 ! \n\n 是否删除'+ title +'下的图片?'))return false;
		editinfo("loading...",title);
		page=1;		
		doajax(date,page);
    }	

    function doajax(date,page){
    	var url="/handle.php?h=project/delpic&uid=<?php echo $pid;?>&pid=<?php echo $project_id?>&date="+date+"&page="+page;
         $.post(url,function(res){
            if(res.state==false){
               alert(res.msg);exit;
            }

            if(res.finish==false){
               myDialog(res.msg);
               doajax(date,res.page);
            }else{   
            	myDialog("删除成功！！"); 
               location.reload(true);             
               return;
            }
         },'json');
    }
</script>
</head>
<body>
	<div class="position_nav">你所在的当前位置：<?php echo $path_str;?></div>
		<div class="main">

		<?php 
		 if($user_info['id']==1){
		?>
			<div class="sos_box">
				<form action="/admin/picremove" id="search" method='get'>				
					<span>项目经理：</span>
				    <select name='pid'>
					   <option value="">请选择</option>
					      <?php 
					      if($result){
					      foreach($result as $key=>$val){
                          ?>
                             <option value="<?php echo $val['id']?>" <?php if($val['id']==$pid){echo "selected";$proj=$val['name'];} ?>><?php echo $val['name']?></option>
                          <?php 
                             }
                          }
					      ?>					 
					</select>						
					<input class="button1" type="submit" value="搜索">
					<a href="/admin/picremovetotal" target="_blank">统一处理</a>
					<font color="red">注意：</font> 只能删除 5 天前的图片数据，删除后不能恢复，请谨慎操作！！
					<input type="hidden" id="project" value="<?php echo $proj;?>">
				</form>
			</div>
			<?php 
			}
			?>
			
			<style>
.dishes_top {
    width: 100%;
}
.dishes_top a{text-decoration: none;}
.dishes_top ul {
    float: left;
    width: 100%;
	margin-top:10px;
}
.dishes_top ul li {
    display: inline-block;
    padding: 0 5px;
}
.dishes_top ul li a {    
    display: block;
    font-size: 14px;
    height: 35px;
    line-height: 35px;
    width: 140px;
	background-color:#eeeeee;
    color: #454545;
    font-size: 14px;
	text-align: center;	
}
.dishes_top ul li a:hover {
    background-color: #79473a;
	color:#ffffff;
}
.dishes_top ul li a.hover {
    background-color: #79473a;
	color:#ffffff;
}			
			</style>

			<div class="dishes_top">
			 <?php 
			   if($project_ary){
			 ?>
			  <ul>
			    <?php 
			      foreach($project_ary as $val){
			    ?>				     		
				 <li><a <?php if($project_id==$val['id']){ ?>class="hover"<?php }?> href="/admin/picremove?pid=<?php echo $pid?>&prid=<?php echo $val['id']?>"><?php echo $val['title']?></a></li>
				 <?php 
				 }
				 ?>			
			  </ul>	
			 <?php 
			 }
			 ?> 
			</div>			
			
			
		    <?php 
		     if(empty($pid)){
		    ?>			
			<table cellpadding="0" cellspacing="1" border="0" class="table" style="margin-top: 20px;">
				<tr>
					<td colspan="8">
						<div class="list_more">
							<font color="red">请选择相应项目项目经理！</font>
						</div>
					</td>
				</tr>						
			</table>
			<?php 
			 }
			?>			
			
			<?php 
			  if($total_ary){
			?>
			<table cellpadding="0" cellspacing="1" border="0" class="table" style="margin-top: 60px;">				    		
	            <tr>
					<th align="center">日期</th>					
					<th align="center">总数</th>
					<th align="center">操作</th>
				</tr>
				
				<?php
				     $_index=''; 						     		 				                 
                     foreach ($total_ary as $v){
				?>			
				<tr>
					<td align="center"><?php echo $v['dates'];?></td>								
					<td align="center"><?php echo $v['sum'];?></td>
					<td align="center">
					      <input class="button1" type="button" value="删除" onclick="del(<?php echo '\''.$v['dates'].'\'' ?>)">
				</tr>	
				<?php 				  
				}
				?>										
			</table>										
			<?php 
			}
			?>
			
				
		    <?php 
		     if($pid && empty($total_ary)){
		    ?>			
			<table cellpadding="0" cellspacing="1" border="0" class="table" style="margin-top: 60px;">
				<tr>
					<td colspan="8">
						<div class="list_more">
							<font color="red">暂无数据 !!</font>
						</div>
					</td>
				</tr>					
			</table>
			<?php 
			 }
			?>							
			
			
		</div>
	</div>
</body>
</html>